﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using ezCloud.Data;

namespace ezCloud.Api.Controllers
{
    [RoutePrefix("api/Test")]
    public class TestController : ApiController
    {
        [Route("Message")]
        public async Task<IHttpActionResult> getMessage(string cmd,int id,string hotelInvoice)
        {
            var context = new ezCloudDataContext();
            ReservationRooms rr = null;
            if(cmd == "showInvoice" || cmd == "hideInvoice")
            {
                rr = context.ReservationRooms.ByReservationRoomId(id).FirstOrDefault();
            }else if (cmd == "showGroupInvoice" || cmd == "hideGroupInvoice")
            {
                rr = context.ReservationRooms.ByReservationId(id).FirstOrDefault();
            }
            //
            if (rr != null)
            {
                Common.extendedScreenHub.SendMessageToHotel((int)rr.HotelId, new { command = cmd, invoiceId = id, hotelInvoice = hotelInvoice });
            }
            return Ok();
        }
    }
}
